from flask import Flask, render_template

app = Flask(__name__)


@app.route('/')
  def hello_world():
    resp = Response(response='Python&Flask', status=201,
                    content_type='text/html'; charset='utf-8')
    res = make_response(args:jsonify({'Python': 'Flask'}),202)
   return res



@app.route('main/<num>', methods=['GET','POST'])
def main(num):
    return render_template(template_name_or_list:'index.html',num=num)


from flask import Flask, g
    app = Flask(__name__)

    @app.route('/')
    def get_user():
        user_id = '001'  # 设置用户id
        user_name = 'flask'  # 设置用户名称
        g.user_id = user_id  # 将用户id保存到g对象中
        g.user_name = user_name  # 将用户名称保存到g对象中
        result = db_query()
        return f'{result}'

    def db_query():
        user_id = g.user_id  # 使用g对象获取用户id
        user_name = g.user_name  # 使用g对象获取用户名称
        return f'{user_id}:{user_name}'



